/**
 * 每日礼包
 */
class DaygiftPanel extends PanelBase {

	public constructor() {
		super();
		this.skinName = DaygiftSkin;
	}



	private list: eui.List;
	private labNum: eui.Label;


	protected createChildren() {
		super.createChildren();

		// 设置标题
		this.commonPanel.setIcon("btn_daygift_png")
		this.commonPanel.setTitle("title_daygift_png");

		// 初始化list
		// 礼包类型 
		// 1 邀请两个人，给一颗奇异果树
		// 2 邀请五个人，再给一颗奇异果树和一袋化肥
		// 3 邀请八个人，再给一棵奇异果树和一袋化肥
		this.list.dataProvider = new eui.ArrayCollection([
			{
				"id": 1,
				"num": 2,
				"list": [{
					"type": 1,
					"pid": 2
				}]
			},
			{
				"id": 2,
				"num": 5,
				"list": [{
					"type": 1,
					"pid": 2
				}, {
					"type": "muck"
				}]
			},
			{
				"id": 3,
				"num": 8,
				"list": [{
					"type": 1,
					"pid": 2
				}, {
					"type": "muck"
				}]
			}
		]);
		this.list.itemRenderer = DaygiftItem;
		this.labNum.text = PlayerSelfData.gift;

		// 今日邀请徒弟数量
		Net.ins.send(['todayChild'], {}, (e) => {
			PlayerSelfData.gift = e.count;
			this.labNum.text = PlayerSelfData.gift;
		});
		// 已领取礼包
		Net.ins.send(['hasGift'], {}, (e) => {
			PlayerSelfData.has_gift = e;
			EventManager.instance.dispatch(EventName.HAS_GIFT_CHANGE, PlayerSelfData.has_gift);
		});
	}

}